<template>
	<view>
		<view style="padding: 200rpx 60rpx 0 60rpx;line-height: 80rpx;">
			<view class="cc-txt-bold" style="font-size: 50rpx;">欢迎登录</view>
			<text>注册登录账号即可查看更多精彩内容</text>
		</view>
		<view style="padding: 30rpx 60rpx;margin-top: 50rpx;">
			<fui-input v-model="form.username" backgroundColor="#F8F8F8" radius="16" borderColor="#f3f3f3" :padding="['30rpx','20rpx']"
				placeholder="用户名">
				<template v-slot:left>
					<view class="fui-left__icon">
						<fui-icon name="my-fill" color="#333" :size="36"/>
					</view>
				</template>
			</fui-input>
		</view>
		<view style="padding: 10rpx 60rpx;">
			<fui-input v-model="form.password" :padding="['30rpx','20rpx']" radius="16" backgroundColor="#F8F8F8"
				borderColor="#f3f3f3" :bottomLeft="0" placeholder="密码" password>
				<template v-slot:left>
					<view class="fui-left__icon">
						<fui-icon name="lock-fill" color="#333" :size="36"/>
					</view>
				</template>
			</fui-input>
		</view>

		<view class="cc-rows cc-flex-center" style="margin-top: 50rpx;">
			<view @click="handleLogin" class="cc-color-white cc-columns cc-flex-center cc-flex-vcenter cc-bg-4c col-85"
				style="border-radius: 80rpx;margin:auto;height: 96rpx;">登录</view>
		</view>
<!-- 		<view class="cc-rows cc-space-between" style="margin-top: 50rpx;padding: 0 60rpx;">
			<text class="cc-size-28" style="color: #666666;">忘记密码</text>
			<view class="">
				<text class="cc-size-28" style="color: #666666;">没有账号？</text>
				<text class="cc-color-4c cc-size-28" @click="goRegister">立即注册</text>
			</view>
		</view> -->
		<view class="margin-t30">
			<fui-divider text="第三方登录" backgroundColor="#fff"/>
		</view>
		<view class="cc-rows cc-flex-center">
			<fui-icon name="wechat" color="#77CB93" :size="90"/>
		</view>
		<view class="cc-columns cc-flex-center cc-flex-vcenter cc-show">
			<view class="">
				<fui-label>
					<view class="fui-align__center " style="margin-top: 80rpx;">
						<fui-checkbox color="#4cccc5" value="1" checked/>
						<text class="fui-text cc-color-999 cc-size-26"
							style="line-height: 10rpx;margin-left: 20rpx;">已阅读并同意途友新能源
							<text class="cc-color-4c">服务协议</text>
							和
							<text class="cc-color-4c">隐私政策</text>
						</text>
					</view>
				</fui-label>
			</view>
		</view>
	</view>
</template>

<script>
	import {ref} from 'vue'
	import { useInfoStore } from '@/stores/info'
	export default {
		setup(){
			const storeInfo = useInfoStore()
			const form=ref({
				username:'',
				password:''
			})
			const isAgree=ref(true)
			return {
				storeInfo,form
			}
		},
		onLoad() {

		},
		methods: {
			getPassword() {
				this.password = !this.password
			},
			handleLogin() {
				if (this.form.username.length<5) {
					return uni.showToast({
					  title: '用户名和密码不能为空~',
					  icon: 'none'
					})
				}
				
				// if (!this.isAgree) {
				// 	return uni.showToast({
				// 		title: '请勾选同意服务协议和隐私政策',
				// 		duration: 2000,
				// 		icon: 'none'
				// 	})
				// }
				uni.publicJs.post('/appLogin',
					{
						username: this.form.username,
						password: this.form.password,
					},
					res=>{
						console.log(res)
						if(res.code===200){
							uni.switchTab({
								url:'/pages/index/index'
							})
							this.storeInfo.loginInit(res.data)
					
						} else {
							uni.showToast({
								title:res.message,icon:'none'
							})
						}
					}
				)
				
			},
			//立即注册
			goRegister() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
		}
	}
</script>

<style lang="scss">
page {background: #fff;}
.fui-left__icon {padding-right: 24rpx;}
</style>